From 68bb5322904402cf5a4105f4f4c20c38032c3851 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 27 Sep 2020 08:57:05 -0400 Subject: [PATCH] window: Don't get surfaces needlessly There is a 1-1 correspondence between natives and surfaces, so we can just compare the natives, no need to get the surface for every single one. --- gtk/gtkwindow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index dccb6644f2..aecafe43be 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -7015,16 +7015,18 @@ update_cursor (GtkWindow *toplevel, { GtkWindowPrivate *priv = gtk_window_get_instance_private (toplevel); GdkCursor *cursor = NULL; + GtkNative *native; GdkSurface *surface; - surface = gtk_native_get_surface (gtk_widget_get_native (target)); + native = gtk_widget_get_native (target); + surface = gtk_native_get_surface (native); if (grab_widget && !gtk_widget_is_ancestor (target, grab_widget) && target != grab_widget) { /* Outside the grab widget, cursor stays to whatever the grab * widget says. */ - if (gtk_native_get_surface (gtk_widget_get_native (grab_widget)) == surface) + if (gtk_widget_get_native (grab_widget) == native) cursor = gtk_widget_get_cursor (grab_widget); else cursor = NULL; @@ -7037,7 +7039,7 @@ update_cursor (GtkWindow *toplevel, while (target) { /* Don't inherit cursors across surfaces */ - if (surface != gtk_native_get_surface (gtk_widget_get_native (target))) + if (native != gtk_widget_get_native (target)) break; if (target == GTK_WIDGET (toplevel) && priv->resize_cursor != NULL) -- 2.30.2